#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define rep(Ii,Jj,Kk) for(int Ii=(Jj),Ii##_=(Kk);Ii<=Ii##_;Ii++)
#define per(Ii,Jj,Kk) for(int Ii=(Jj),Ii##_=(Kk);Ii>=Ii##_;Ii--)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned uint;
typedef long double db;
#define fir first
#define sec second
#define siz(Aa) ((int)(Aa).size())
#define all(Aa) (Aa).begin(),(Aa).end()
#define ckmx(Aa,Bb) (Aa=max(Aa,Bb))
#define ckmn(Aa,Bb) (Aa=min(Aa,Bb))
#define Fi(s) freopen(s,"r",stdin)
#define Fo(s) freopen(s,"w",stdout)
#define Fre(s) Fi(s".in"),Fo(s".out")

int n,m;
bool flag=false;
void o(int x,int y){
	if(flag) cout<<y<<" "<<x<<"\n";
	else cout<<x<<" "<<y<<"\n";
}
signed main(){ios::sync_with_stdio(false),cin.tie(nullptr);
	Fre("bishop");
	cin>>n>>m;
	if(n==m){
		if(n==1){
			cout<<"1\n1 1\n";	
		}else{
			cout<<2*n-2<<"\n";
			rep(i,1,n-1) cout<<"1 "<<i<<"\n"<<n<<" "<<i<<"\n";
		}
		return 0;
	}
	if(n>m) swap(n,m),flag=true;
	if(~n&1 && ~m&1) cout<<n+m-2<<"\n";
	else cout<<n+m-1<<"\n";
	rep(i,1,n) o(i,1),o(i,m);
	if(n&1){
		rep(j,(n+3)>>1,m+1-((n+3)>>1)) o((n+1)>>1,j);
	}else{
		for(int j=(n+4)>>1,jj=m+1-((n+4)>>1);j<=jj;j+=2){
			o(n>>1,j);
			o((n+2)>>1,j);
		}
	}
return 0;}
/*
*/